﻿<CustomWindow:EssentialWindow 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:aero="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    xmlns:CustomWindow="clr-namespace:CustomWindow;assembly=CustomWindow"
  mc:Ignorable="d" 
  xmlns:TwitterLib="clr-namespace:TwitterLib;assembly=TwitterLib" 
  xmlns:Pawing="clr-namespace:Pawing" 
  xmlns:controls="clr-namespace:Common.Controls;assembly=Common" 
  xmlns:converters="clr-namespace:Common.Converters;assembly=Common"
  xmlns:r="clr-namespace:PixelLab.Wpf;assembly=PixelLab.Wpf"
    xmlns:t="clr-namespace:PixelLab.Wpf.Transitions;assembly=PixelLab.Wpf"
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  xmlns:Search="clr-namespace:Pawing.Controls.Search"
  AllowsTransparency="True" Background="Transparent" 
  ResizeMode="NoResize"
  x:Class="Pawing.MainWindow" 
  Title="Pawing 2.0" 
  Width="380" Height="570" MinWidth="200" MinHeight="200" 
  WindowStyle="None"
  ShowInTaskbar="True"
  KeyDown="MainWindow_OnKeyDown" Left="800" Top="50" LocationChanged="EssentialWindow_LocationChanged" MouseEnter="EssentialWindow_MouseEnter" MouseLeave="EssentialWindow_MouseLeave" MouseMove="EssentialWindow_MouseMove" Topmost="True">

	<CustomWindow:EssentialWindow.Resources>
		<ResourceDictionary>
			<!-- Placed storyboard animations in their own file to condense the markup -->
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="Resources\Storyboards.xaml" />
			</ResourceDictionary.MergedDictionaries>

			<converters:CharRemainingValueConverter x:Key="CharRemainingConverter" />
			<converters:CharRemainingForegroundColorConverter x:Key="CharRemainingColorConverter" />
		</ResourceDictionary>
	</CustomWindow:EssentialWindow.Resources>

	<CustomWindow:EssentialWindow.Triggers>
		<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="Update">
			<BeginStoryboard Storyboard="{StaticResource UpdateMouseEnter}" x:Name="UpdateMouseEnter_BeginStoryboard" />
		</EventTrigger>
		<EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="Update">
			<BeginStoryboard Storyboard="{StaticResource UpdateMouseLeave}" x:Name="UpdateMouseLeave_BeginStoryboard" />
		</EventTrigger>
		<EventTrigger RoutedEvent="Mouse.MouseEnter" SourceName="Message">
			<BeginStoryboard Storyboard="{StaticResource MessageMouseEnter}" x:Name="MessageMouseEnter_BeginStoryboard" />
		</EventTrigger>
		<EventTrigger RoutedEvent="Mouse.MouseLeave" SourceName="Message">
			<BeginStoryboard Storyboard="{StaticResource MessageMouseLeave}" x:Name="MessageMouseLeave_BeginStoryboard" />
		</EventTrigger>
	</CustomWindow:EssentialWindow.Triggers>

	<Border BorderBrush="#55FFFFFF" BorderThickness="1" CornerRadius="5" Margin="2,1,-1,-1">
		<DockPanel x:Name="LayoutRoot">
			<!-- Header -->
			<Border DockPanel.Dock="Top" Height="40" Padding="10,0,10,0" CornerRadius="5,5,0,0" x:Name="Header" MouseMove="Header_MouseMove" Background="{DynamicResource PrimaryBackgroundBrush}" Margin="-1,0,1,0">
				<Border.ContextMenu>
					<ContextMenu>
						<MenuItem x:Name="AlwaysOnTopMenuItem" Header="Always on Top" IsCheckable="True" Click="AlwaysOnTop_Click" IsChecked="{Binding Topmost, ElementName=Window, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
					</ContextMenu>
				</Border.ContextMenu>
				<DockPanel LastChildFill="False">
					<TextBlock Text="Pawing" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="18" FontWeight="Bold" Foreground="{DynamicResource HeaderForegroundBrush}" />
					<Border x:Name="WindowButtonsPlaceholder" HorizontalAlignment="Right" VerticalAlignment="Top" DockPanel.Dock="Right" Margin="0" />
					<Button Content="刷新" Height="15" x:Name="RefreshButton" Click="RefreshButton_Click" IsEnabled="False" MinWidth="25" MinHeight="20" FontSize="9" DockPanel.Dock="Right" Margin="0,0,10,0" Width="50" ToolTip="更新微博" />
					<Button Content="设置" Height="15" x:Name="OptionsButton" Click="OptionsButton_Click" MinWidth="25" MinHeight="20" FontSize="9" DockPanel.Dock="Right" Margin="0,0,5,0" IsEnabled="True" Width="50" ToolTip="显示设置窗口" />
					<ToggleButton Content="Filter" Height="25" x:Name="FilterToggleButton" MinWidth="25" MinHeight="20" FontSize="9" IsEnabled="False" Width="55" ToolTip="显示过滤界面" DockPanel.Dock="Right" BorderThickness="1,1,1,1" Margin="0,0,10,0" IsChecked="False" Unchecked="FilterToggleButton_Unchecked" Background="{DynamicResource NormalBrush}" Foreground="{DynamicResource LightBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" Visibility="Visible">
						<ToggleButton.Clip>
							<RectangleGeometry Rect="3,3,50,20" RadiusX="5" RadiusY="5" />
						</ToggleButton.Clip>
					</ToggleButton>
				</DockPanel>

			</Border>

			<!-- Filter  -->
			<Border DockPanel.Dock="Top" x:Name="Filter" Background="#FFCEE8B9" IsEnabled="False">
				<r:Reveal 
  			VerticalReveal="FromTopToBottom" 
  			IsExpanded="{Binding IsChecked, ElementName=FilterToggleButton}" HorizontalAlignment="Left">
					<DockPanel Margin="0,0,5,5" VerticalAlignment="Stretch">
						<Label Content="Filter" Target="{Binding ElementName=FilterTextBox, Mode=OneWay}"/>
						<controls:FilterText x:Name="FilterTextBox" TextBoxBase.TextChanged="FilterTextBox_TextChanged" Width="150"/>
						<Button Content="Search with TweetScan" Height="20" Margin="10,0,0,0" x:Name="TweetScanButton" FontSize="9" Click="TweetScanButton_Click" Visibility="Collapsed"/>
					</DockPanel>
				</r:Reveal>
			</Border>

			<!-- StatusBar-->
			<Border DockPanel.Dock="Bottom" Padding="5,2,0,2" CornerRadius="0,0,5,5" Background="{DynamicResource StatusBackgroundBrush}" x:Name="StatusBar">
				<DockPanel>
					<TextBlock DockPanel.Dock="Left" x:Name="StatusTextBlock" TextWrapping="NoWrap" Foreground="#FFE4E4E4" Text="Login" TextTrimming="CharacterEllipsis" />
					
                    <Thumb DockPanel.Dock="Right" HorizontalAlignment="Right" VerticalAlignment="Bottom" Cursor="SizeNWSE" DragDelta="Thumb_DragDelta" Width="11" Height="11" DragOver="Thumb_DragOver">
                        <Thumb.Template>
                            <ControlTemplate>
                                <Canvas>
                                    <Image Source="Resources/grip.png" Stretch="None" HorizontalAlignment="Right" VerticalAlignment="Bottom"  Canvas.Right="2" />
                                </Canvas>
                            </ControlTemplate>
                        </Thumb.Template>
                    </Thumb>
                    
				</DockPanel>
			</Border>

			<!-- Main Content -->
			<Grid x:Name="Content"  AllowDrop="True" PreviewDragEnter="Recent_PreviewDragOver" PreviewDragOver="Recent_PreviewDragOver" PreviewDrop="Recent_Drop" >
                <TabControl x:Name="Tabs"  DockPanel.Dock="Top"  ContentTemplate="{DynamicResource TabTemplate}" SelectionChanged="Tabs_SelectionChanged" Margin="0,-3,0,0" >

                    <!-- Recent Tab -->
                    <TabItem Header="最新" Padding="1,1,1,1" x:Name="RecentTab">
                        <Grid x:Name="Recent">
                            <ListBox x:Name="TweetsListBox"
                                     ScrollViewer.ScrollChanged="TweetsListBox_ScrollChanged" ScrollViewer.CanContentScroll="False" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                     IsSynchronizedWithCurrentItem="True" 
                                     ItemTemplate="{DynamicResource TweetsTemplate}" ItemsSource="{Binding Mode=OneWay}"  
                                     Margin="0,0,0,20" BorderThickness="0,0,0,0"
                                     MouseLeftButtonUp="TweetsListBox_MouseLeftButtonUp" MouseRightButtonUp="TweetsListBox_MouseRightButtonUp" PreviewMouseLeftButtonDown="TweetsListBox_PreviewMouseLeftButtonDown"
                                     controls:TweetTextBlock.NameClick="NameClickedInTweet" controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet">
                                <ListBox.ContextMenu>
                                    <ContextMenu x:Name="recentContextMenu">
                                        <MenuItem Header="转发" Click="ContextMenuRetweet_Click" />
                                        <MenuItem Header="发送私信" Click="ContextMenuDirectMessage_Click" />
                                        <MenuItem Header="删除" Click="ContextMenuDelete_Click" IsEnabled="True" />
                                        <MenuItem Header="回复" Click="ContextMenuReply_Click" IsEnabled="True" />
                                        <MenuItem Header="查看回复" Click="ContextMenuConversation_Click" />
                                        <MenuItem Header="刷新" Click="RefreshButton_Click" />
                                        <MenuItem Header="清除所有微博" Click="ContextMenuClear_Click" />
                                        <MenuItem Header="临时忽略此用户" Click="ContextMenuIgnore_Click" />
                                    </ContextMenu>
                                </ListBox.ContextMenu>
                            </ListBox>  
                            <Border Height="21" Background="{StaticResource UpdateBackgroundBrush}" VerticalAlignment="Bottom" Padding="2,0" x:Name="Update" MouseLeftButtonUp="Update_MouseLeftButtonUp" BorderBrush="{DynamicResource PrimaryBackgroundBrush}" BorderThickness="0,0,0,1" ToolTip="显示发布界面">
                                <DockPanel OpacityMask="#FF000000" x:Name="dockPanel">
                                    <TextBlock HorizontalAlignment="Center" DockPanel.Dock="Top" Text="我要说" TextWrapping="Wrap" VerticalAlignment="Top" x:Name="UpdateTextBlock" Margin="0,2,0,0" />
                                    <Grid Margin="0,2,0,0" KeyboardNavigation.TabNavigation="Cycle">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="152*" />
                                            <ColumnDefinition Width="49*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid Grid.ColumnSpan="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" MaxWidth="100"/>
                                                <ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                                <TextBox Grid.Column="1" Text="" TextWrapping="Wrap" x:Name="TweetTextBox" SpellCheck.IsEnabled="True" ToolTip="Enter tweet (140 character limit)" PreviewKeyDown="TweetTextBox_PreviewKeyDown" 
                                          DataObject.Pasting="TweetTextBox_OnPaste" TextChanged="TweetTextBox_TextChanged" Height="66" TabIndex="1" AllowDrop="True" PreviewDragEnter="Recent_PreviewDragOver" PreviewDragOver="Recent_PreviewDragOver" PreviewDrop="Recent_Drop" />
<TextBlock Grid.Column="1" Text="{Binding Text, Converter={StaticResource CharRemainingConverter}, ElementName=TweetTextBox, Mode=Default}" FontSize="18" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,5,8" FontFamily="Georgia" x:Name="CharRemainingCounter" Foreground="{Binding Text.Length, Converter={StaticResource CharRemainingColorConverter}, ElementName=TweetTextBox}" />
                                            <r:Reveal 
  			VerticalReveal="FromTopToBottom" 
  			IsExpanded="{Binding ElementName=imagePresenter, Path=IsVisible}" HorizontalAlignment="Left">
                                                <Image Grid.Column="0" x:Name="imagePresenter" ToolTip="点击删除图片" Margin="0,0,2,0" Opacity="0.4"  MaxHeight="66" Stretch="Uniform" MouseEnter="imagePresenter_MouseEnter"  HorizontalAlignment="Left" MouseLeave="imagePresenter_MouseLeave" MouseLeftButtonUp="imagePresenter_MouseLeftButtonUp" />
                                        </r:Reveal> 
                                            </Grid>
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="发布" Grid.Column="2" x:Name="UpdateButton" Click="UpdateButton_Click" Margin="10,0,5,55" IsDefault="True" ToolTip="Submit update" TabIndex="2" HorizontalAlignment="Right" />
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="表情" Grid.Column="2" x:Name="AddEmotButton" Margin="10,0,5,30" IsDefault="True" ToolTip="添加表情" TabIndex="3" HorizontalAlignment="Right" Click="AddEmotButton_Click" />
										<Button Width="75" Height="23" VerticalAlignment="Bottom" Content="图片" Grid.Column="2" x:Name="AddPicButton" Margin="10,0,5,5" IsDefault="True" ToolTip="添加图片" TabIndex="4" Click="AddPicButton_Click" HorizontalAlignment="Right" />
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="取消" Grid.Column="2" x:Name="CancelButton" Click="CancelButton_Click" Margin="10,0,5,5" ToolTip="Clear text and hide update panel" TabIndex="5" Visibility="Collapsed" HorizontalAlignment="Right" d:IsHidden="True" />
                                    </Grid>
                                </DockPanel>
                            </Border>
                        </Grid>
                    </TabItem>
                    <!-- Mentions Tab -->
                    <TabItem Header="@我" Padding="1,1,1,1" x:Name="MentionsTab">
                        <ListBox x:Name="MentionsListBox"
                                 ScrollViewer.ScrollChanged="MentionsListBox_ScrollChanged" ScrollViewer.CanContentScroll="False" IsSynchronizedWithCurrentItem="True" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                 ItemTemplate="{DynamicResource TweetsTemplate}"  
                                 MouseLeftButtonUp="TweetsListBox_MouseLeftButtonUp" MouseRightButtonUp="MentionsListBox_MouseRightButtonUp" PreviewMouseLeftButtonDown="TweetsListBox_PreviewMouseLeftButtonDown"
                                 BorderThickness="0,0,0,0" 
                                 controls:TweetTextBlock.NameClick="NameClickedInTweet" controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet">
                            <ListBox.ContextMenu>
                                <ContextMenu x:Name="MentionsContextMenu">
                                    <MenuItem Header="转发" Click="ContextMenuRetweet_Click" />
                                    <!--<MenuItem Header="Reply to All" Click="ContextMenuReplyAll_Click" />-->
                                    <MenuItem Header="关注" Click="ContextMenuFollow_Click" IsEnabled="True" />
                                    <MenuItem Header="发送私信" Click="ContextMenuDirectMessage_Click" />
                                    <MenuItem Header="回复" Click="ContextMenuRetweet_Click" IsEnabled="True" />
                                    <MenuItem Header="查看回复" Click="ContextMenuConversation_Click" />
                                    <MenuItem Header="刷新" Click="RefreshButton_Click" />
                                    <MenuItem Header="清除所有微博" Click="ContextMenuClear_Click" />
                                </ContextMenu>
                            </ListBox.ContextMenu>
                        </ListBox>
                    </TabItem>
                    <!-- User Tab -->
					<TabItem x:Name="UserTab" Header="用户" Padding="1,1,1,1">
						<DockPanel>
							<Border DockPanel.Dock="Top" BorderBrush="{DynamicResource SolidBorderBrush}" BorderThickness="0,0,0,1">
								<Border.Background>
									<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
										<GradientStop Color="#FFD0DBE7" Offset="0" />
										<GradientStop Color="#FFFFFFFF" Offset="1" />
									</LinearGradientBrush>
								</Border.Background>
								<Grid>
									<Grid.ColumnDefinitions>
										<ColumnDefinition Width="80" />
										<ColumnDefinition Width="*" />
									</Grid.ColumnDefinitions>
									<Grid VerticalAlignment="Top" HorizontalAlignment="Center" Margin="0,12,0,0" Width="58" Height="60">
										<aero:SystemDropShadowChrome CornerRadius="5,5,5,5">
											<Rectangle Stroke="#FF8E8E8E" RadiusX="10" RadiusY="5">
												<Rectangle.Fill>
													<LinearGradientBrush EndPoint="0.869,0.837" StartPoint="0.278,0.298">
														<GradientStop Color="#FFFFFFFF" Offset="0"/>
														<GradientStop Color="#FF7BB2B7" Offset="1"/>
													</LinearGradientBrush>
												</Rectangle.Fill>
											</Rectangle>
										</aero:SystemDropShadowChrome>
										<Border BorderBrush="{DynamicResource ImageBorderBrush}" BorderThickness="1,1,1,1" Margin="4,5,4,5" CornerRadius="2,2,2,2">
											<Image Width="48" Height="48" Source="{Binding User.ImageUrl}" x:Name="UserImage" />
										</Border>
									</Grid>
									<Grid Grid.Column="1" Margin="0,10,0,0">
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="*" />
										</Grid.RowDefinitions>
										<TextBlock Text="{Binding User.FullName, FallbackValue=Full Name}" FontWeight="Bold" FontSize="16" x:Name="FullName" Cursor="Hand" MouseLeftButtonUp="ScreenName_MouseLeftButtonUp" Tag="{Binding User.TwitterUrl, Mode=Default}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" ToolTip="{Binding User.TwitterUrl, Mode=Default}" d:LayoutOverrides="Width, Height" />
										<DockPanel Grid.Row="1">
											<TextBlock x:Name="Description" Text="{Binding User.Description, Mode=Default, FallbackValue=Description}" TextWrapping="Wrap" FontStyle="Italic" DockPanel.Dock="Top" />
											<TextBlock x:Name="SiteUrl" Text="{Binding User.SiteUrl, Mode=Default, FallbackValue=Site Url}" TextWrapping="NoWrap" MouseLeftButtonUp="Url_MouseLeftButtonUp" Cursor="Hand" TextTrimming="CharacterEllipsis" DockPanel.Dock="Top" ToolTip="{Binding User.SiteUrl, Mode=Default}" TextDecorations="Underline" Foreground="#FF0000FF"><Hyperlink NavigateUri="{Binding User.SiteUrl, Mode=Default, FallbackValue=Site Url}" /></TextBlock>
											<TextBlock x:Name="Location" Text="{Binding User.Location, Mode=Default, FallbackValue=Location}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
										</DockPanel>
									</Grid>
								</Grid>
							</Border>
							<ListBox  x:Name="UserTimelineListBox" ScrollViewer.ScrollChanged="UserTimelineListBox_ScrollChanged" ItemsSource="{Binding Mode=OneWay}" ScrollViewer.CanContentScroll="False" IsSynchronizedWithCurrentItem="True" ItemTemplate="{DynamicResource UserTimeLineTemplate}" ScrollViewer.HorizontalScrollBarVisibility="Disabled" MouseLeftButtonUp="TweetsListBox_MouseLeftButtonUp" MouseRightButtonUp="UserTimelineListBox_MouseRightButtonUp" BorderThickness="0,0,0,0" DockPanel.Dock="Bottom" 
              controls:TweetTextBlock.NameClick="NameClickedInTweet"
              controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet">
								<ListBox.ContextMenu>
									<ContextMenu x:Name="UserContextMenu">
										<MenuItem Header="转发" Click="ContextMenuRetweet_Click"/>
										<MenuItem Header="Reply to All" Click="ContextMenuReplyAll_Click"/>
										<MenuItem Header="Follow" Click="ContextMenuFollow_Click" IsEnabled="True"/>
										<MenuItem Header="发送私信" Click="ContextMenuDirectMessage_Click"/>
										<MenuItem Header="删除" Click="ContextMenuDelete_Click" IsEnabled="True"/>
										<MenuItem Header="回复" Click="ContextMenuRetweet_Click" IsEnabled="True"/>
										<MenuItem Header="查看回复" Click="ContextMenuConversation_Click"/>
										<MenuItem Header="刷新" Click="RefreshButton_Click"/>
										<MenuItem Header="清除所有微博" Click="ContextMenuClear_Click"/>

									</ContextMenu>
								</ListBox.ContextMenu>
							</ListBox>
						</DockPanel>
					</TabItem>
					<!-- Messages Tab -->
					<TabItem Header="私信" Padding="1,1,1,1" x:Name="MessagesTab">
						<Grid x:Name="Messages">
                            <ListBox x:Name="MessagesListBox" BorderThickness="0,0,0,0" Margin="0,0,0,20"
                                     ScrollViewer.ScrollChanged="MessagesListBox_ScrollChanged" ScrollViewer.CanContentScroll="False" IsSynchronizedWithCurrentItem="True"  ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                     ItemTemplate="{DynamicResource MessagesTemplate}" ItemsSource="{Binding Mode=OneWay}"
                                     MouseLeftButtonUp="MessagesListBox_MouseLeftButtonUp"  PreviewMouseLeftButtonDown="MessagesListBox_PreviewMouseLeftButtonDown"
              controls:TweetTextBlock.NameClick="NameClickedInTweet"
              controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet" >
								<ListBox.ContextMenu>
									<ContextMenu x:Name="MessagesContextMenu">
										<MenuItem Header="转发" Click="ContextMenuRetweet_Click"/>
										<MenuItem Header="发送私信" Click="ContextMenuDirectMessage_Click"/>
										<MenuItem Header="删除" Click="ContextMenuDeleteMessage_Click" IsEnabled="True"/>
										<MenuItem Header="回复" Click="ContextMenuRetweet_Click" IsEnabled="True"/>
									</ContextMenu>
								</ListBox.ContextMenu>
							</ListBox>
							<Border Height="21" Background="{StaticResource UpdateBackgroundBrush}" VerticalAlignment="Bottom" Padding="10,0,10,0" x:Name="Message" MouseLeftButtonUp="Message_MouseLeftButtonUp" BorderBrush="{DynamicResource PrimaryBackgroundBrush}" BorderThickness="0,0,0,1" CornerRadius="0,0,5,5" >
								<DockPanel OpacityMask="#FF000000" x:Name="MessageDockPanel">
									<TextBlock HorizontalAlignment="Center" DockPanel.Dock="Top" Text="发私信" TextWrapping="Wrap" VerticalAlignment="Top" x:Name="MessageTextBlock" Margin="0,2,0,0" />
									<Grid Margin="0,5,0,0">
										<Grid.RowDefinitions>
											<RowDefinition Height="Auto" />
											<RowDefinition Height="*" />
										</Grid.RowDefinitions>
										<Grid.ColumnDefinitions>
											<ColumnDefinition Width="*" />
											<ColumnDefinition Width="Auto" />
										</Grid.ColumnDefinitions>
										<StackPanel Orientation="Horizontal">
											<TextBlock Text="To:" TextWrapping="Wrap" Margin="0,0,5,0" VerticalAlignment="Center" />
											<TextBox Text="" TextWrapping="Wrap" VerticalAlignment="Center" Width="120" Margin="0,0,0,2" x:Name="MessageUserTextBox" />
										</StackPanel>
										<TextBox Grid.Row="1" Text="" Margin="0,0,0,6" TextWrapping="Wrap" x:Name="MessageTextBox" SpellCheck.IsEnabled="True" />
										<TextBlock	Grid.Row="1" 
								Text="{Binding Text, Converter={StaticResource CharRemainingConverter}, ElementName=MessageTextBox, Mode=Default}" 
								FontSize="18" 
								Grid.Column="0" 
								VerticalAlignment="Bottom" 
								HorizontalAlignment="Right" 
								Margin="0,0,5,8" 
								FontFamily="Georgia" 
								x:Name="MessageCharRemainingCounter"
								Foreground="{Binding Text.Length, Converter={StaticResource CharRemainingColorConverter}, ElementName=MessageTextBox}" />

                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="表情" Grid.Column="1" Grid.Row="1" x:Name="MessageAddEmotButton" Margin="10,0,0,4"  IsDefault="True" ToolTip="添加表情" TabIndex="3" HorizontalAlignment="Right" Click="AddEmotButton_Click" />
                                        <Button VerticalAlignment="Bottom" Width="75" Height="23" Content="发送" Grid.Column="1" Grid.Row="1" x:Name="SendMessageButton" Click="SendMessageButton_Click" Margin="10,0,0,30" IsDefault="True" />
									</Grid>
								</DockPanel>
							</Border>
						</Grid>
					</TabItem>
                    <!--Replies Tab-->
                    <TabItem Header="回复" Padding="1,1,1,1" x:Name="RepliesTab">
                        <Grid x:Name="Replies">
                            <ListBox x:Name="RepliesListBox" 
                                     ScrollViewer.ScrollChanged="RepliesListBox_ScrollChanged" ScrollViewer.CanContentScroll="False" IsSynchronizedWithCurrentItem="True" 
                                     ItemTemplate="{DynamicResource RepliesTemplate}" ItemsSource="{Binding Mode=OneWay}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                                     Margin="0,0,0,20"  BorderThickness="0,0,0,0" 
                                     MouseLeftButtonUp="TweetsListBox_MouseLeftButtonUp" MouseRightButtonUp="RepliesListBox_MouseRightButtonUp" PreviewMouseLeftButtonDown="TweetsListBox_PreviewMouseLeftButtonDown"
                                     controls:TweetTextBlock.NameClick="NameClickedInTweet" controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet">
                                <ListBox.ContextMenu>
                                    <ContextMenu x:Name="ReplyContextMenu">
                                        <MenuItem Header="转发" Click="ContextMenuRetweet_Click" />
                                        <MenuItem Header="发送私信" Click="ContextMenuDirectMessage_Click" />
                                        <MenuItem Header="删除" Click="ContextMenuDelete_Click" IsEnabled="True" />
                                        <MenuItem Header="回复" Click="ContextMenuReply_Click" IsEnabled="True" />
                                        <MenuItem Header="查看回复" Click="ContextMenuConversation_Click" />
                                        <MenuItem Header="刷新" Click="RefreshButton_Click" />
                                        <MenuItem Header="清除所有微博" Click="ContextMenuClear_Click" />
                                        <!--<MenuItem Header="临时忽略此用户" Click="ContextMenuIgnore_Click" />-->
                                    </ContextMenu>
                                </ListBox.ContextMenu>
                            </ListBox>
                            <Border Height="21" Background="{StaticResource UpdateBackgroundBrush}" MouseLeftButtonUp="Reply_MouseLeftButtonUp" VerticalAlignment="Bottom" Padding="2,0" x:Name="Reply" BorderBrush="{DynamicResource PrimaryBackgroundBrush}" BorderThickness="0,0,0,1" ToolTip="Display reply panel">
                                <DockPanel OpacityMask="#FF000000" x:Name="ReplyDockPanel">
                                    <TextBlock HorizontalAlignment="Center" DockPanel.Dock="Top" Text="回复" TextWrapping="Wrap" VerticalAlignment="Top" x:Name="ReplyTextBlock" Margin="0,2,0,0" />
                                    <Grid Margin="0,2,0,0" KeyboardNavigation.TabNavigation="Cycle">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="152*" />
                                            <ColumnDefinition Width="49*" />
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>
                                        <Grid Grid.ColumnSpan="2">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="Auto" MaxWidth="100"/>
                                                <ColumnDefinition/>
                                            </Grid.ColumnDefinitions>
                                            <TextBox Grid.Column="1" Text="" TextWrapping="Wrap" x:Name="ReplyTextBox" SpellCheck.IsEnabled="True" ToolTip="Enter tweet (140 character limit)" PreviewKeyDown="ReplyTextBox_PreviewKeyDown" 
                                          DataObject.Pasting="ReplyTextBox_OnPaste" TextChanged="ReplyTextBox_TextChanged" Height="66" TabIndex="1" AllowDrop="True" PreviewDragEnter="Replies_PreviewDragOver" PreviewDragOver="Replies_PreviewDragOver" PreviewDrop="Replies_Drop" />
                                            <TextBlock Grid.Column="1" Text="{Binding Text, Converter={StaticResource CharRemainingConverter}, ElementName=ReplyTextBox, Mode=Default}" FontSize="18" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,5,8" FontFamily="Georgia" x:Name="ReplyCharRemainingCounter" Foreground="{Binding Text.Length, Converter={StaticResource CharRemainingColorConverter}, ElementName=ReplyTextBox}" />
                                        </Grid>
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="发布" Grid.Column="2" x:Name="ReplyUpdateButton" Click="ReplyUpdateButton_Click" Margin="10,0,5,55" IsDefault="True" ToolTip="Submit update" TabIndex="2" HorizontalAlignment="Right" />
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="表情" Grid.Column="2" x:Name="ReplyAddEmotButton" Margin="10,0,5,30" IsDefault="True" ToolTip="添加表情" TabIndex="3" HorizontalAlignment="Right" Click="AddEmotButton_Click" />
                                        <Button Width="75" Height="23" VerticalAlignment="Bottom" Content="取消" Grid.Column="2" x:Name="ReplyCancelButton" Click="CancelReply_Click" Margin="10,0,5,5" ToolTip="Clear text and hide update panel" TabIndex="5" HorizontalAlignment="Right" d:IsHidden="True" />
                                    </Grid>
                                </DockPanel>
                            </Border>
                        </Grid>
                    </TabItem>
                    <!-- Search Tab-->
					<TabItem Header="搜索" Padding="1,1,1,1" x:Name="SearchTab">
						<Grid>
                            <Search:TweetHunt x:Name="SearchContent" MouseLeftButtonUp="SearchContent_MouseLeftButtonUp"  NameClickedInTweetHunt="NameClickedInTweet" HashtagClickedInTweetHunt="HashtagClickedInTweet" />
							<ListBox x:Name="MoreListBox" ScrollViewer.CanContentScroll="False" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Mode=OneWay}" ItemTemplate="{DynamicResource MoreTemplate}"  ScrollViewer.HorizontalScrollBarVisibility="Disabled" Margin="0,0,0,20"  BorderThickness="0,0,0,0"
              controls:TweetTextBlock.NameClick="NameClickedInTweet" 
              controls:TweetTextBlock.HashtagClick="HashtagClickedInTweet" Visibility="Collapsed">
							</ListBox>
						</Grid>
					</TabItem>
				</TabControl>
				<!-- Login Control -->
				<Pawing:LoginControl HorizontalAlignment="Center"  VerticalAlignment="Center" x:Name="LoginControl" Login="LoginControl_Login" Loaded="LoginControl_Loaded" Visibility="Visible" BitmapEffect="{DynamicResource LoginBitmapEffect}"/>

                <Grid.Resources>
                    <DataTemplate x:Key="TabTemplate">
                        <t:TransitionPresenter Content="{Binding}">
                            <t:TransitionPresenter.Transition>
                                <t:RotateTransition Duration="0:0:0.45" FieldOfView="40" Angle="0"></t:RotateTransition>
                            </t:TransitionPresenter.Transition>
                        </t:TransitionPresenter>
                    </DataTemplate>
                </Grid.Resources>
            </Grid>
		</DockPanel>
	</Border>
</CustomWindow:EssentialWindow>
